Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit b2a5b8c193549b1c1d3bb6110d6da44c07ee7a9c


Parents : ad58ab3
Author : Mark Qvist <mark@unsigned.io>
Date : 2024-12-09T12:25:59+01:00

Added detection of failed markup rendering, and plaintext fallback

Changes

2 files changed, 12 insertions(+), 4 deletions(-)


Diff

diff --git a/sbapp/ui/helpers.py b/sbapp/ui/helpers.py
index 68f73d44..b1bda898 100644
--- a/sbapp/ui/helpers.py
+++ b/sbapp/ui/helpers.py
@@ -45,10 +45,6 @@ def strip_emojis(str_input):
return output
def multilingual_markup(data):
- # TODO: Remove
- # import time
- # ts = time.time()
-
do = ""
rfont = "default"
ds = data.decode("utf-8")
@@ -95,6 +91,10 @@ def multilingual_markup(data):
return do.encode("utf-8")
+font_map = {
+ "mono": "RobotoMono-Regular"
+}
+
codepoint_map = {
0x0590: [0x05ff, "hebrew"],
0x2e3a: [0x2e3b, "chinese"],

diff --git a/sbapp/ui/messages.py b/sbapp/ui/messages.py
index 2047ecf4..b77da509 100644
--- a/sbapp/ui/messages.py
+++ b/sbapp/ui/messages.py
@@ -653,6 +653,14 @@ class Messages():
item.ids.content_text.owner = item
item.ids.content_text.bind(texture_size=check_textures)
+ def cbf(w):
+ def x(dt):
+ if w.texture_size[0] == 0 and w.texture_size[1] == 0:
+ w.text = "[i]This message could not be rendered, likely due to an error in its markup. Falling back to plain-text rendering.[/i]\n\n"+escape_markup(w.text)
+ return x
+
+ Clock.schedule_once(cbf(item.ids.content_text), 0.25)
+
if not RNS.vendor.platformutils.is_android():
item.radius = dp(5)


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────